from django.db import models

# Create your models here.
from django.db.models import BooleanField as _BooleanField
import uuid
from django.db.models.functions.datetime import Now


class BooleanField(_BooleanField):

    def get_prep_value(self, value):
        if value in ("0", "false", "False", 0):
            return False
        elif  value in ("1", "true", "True", 1):
            return True
        else:
            return super(BooleanField, self).get_prep_value(value)


# Create your models here.
class Demo(models.Model):
    # id = models.UUIDField(primary_key=True, auto_created=True, default=uuid.uuid4,)
    id = models.CharField(max_length=32, primary_key=True)
    name = models.CharField('活动名称', max_length=100, null=True, blank=True,)
    region = models.CharField(max_length=100, null=True, blank=True,)
    imgs = models.CharField('图片', max_length=1500, null=True,)
    date1 = models.DateTimeField('活动开始日期-自动', auto_now_add=True,)
    date2 = models.DateTimeField('活动结束时间')
    delivery = BooleanField('是否', null=True,)
    classify = models.CharField('货物名称', max_length=200, null=True, blank=True,)
    resource = models.CharField('货物信息', max_length=200, null=True, blank=True,)
    remarks = models.CharField('货物备注', max_length=100, null=True, blank=True,)
    
    class Meta:
        db_table = 'just_demo'
        ordering = []

    
def get_id(self):
    return self.id
